package org.hong.h12.controller;

import org.hong.h12.commom.Response;
import org.hong.h12.entity.Student;
import org.hong.h12.service.student.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/student")
public class StudentController {
    @Autowired
    StudentService studentService;

    @GetMapping("/all")
    public Response allStudent() {
         List<Student> students =studentService.allStudent();
        System.out.println(students);
        return Response.ok(students);
    }
    @GetMapping("/selectAll")
    public Response selectAll(Student student) {
        List<Student> students =studentService.StudentSelectAll(student);
        System.out.println(students);
        return Response.ok(students);
    }



    @PutMapping("/add")
    public Response addStudent(Student student) {
        Student student1 = studentService.StudentAddAndInsert(student);
        return Response.ok(0);
    }

}

